package com.walleipt;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.InetAddress;
import java.net.MulticastSocket;
import java.net.UnknownHostException;

public class Recver {

    public static void main(String[] args) {

        try {
            InetAddress group = InetAddress.getByName("228.5.6.7") ;
            MulticastSocket socket = new MulticastSocket(2222) ;
            socket.joinGroup(group);

            byte[] buf = new byte[10000] ;
            DatagramPacket recv = new DatagramPacket(buf, buf.length ) ;

            while (true)
            {
                try {
                    Thread.sleep( 3000 );
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                socket.receive(recv);
                System.err.println(new String(buf));
            }
        } catch (UnknownHostException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
